You are here: Symbol Reference > Dew Namespace > Dew.Math Namespace > Classes > TMtxExpression Class > TMtxExpression Methods > DefineMatrix Method > TMtxExpression.DefineMatrix Method ([In] string, [In] TMtx)
Dew Math for .NET
ContentsIndexHome
PreviousUpNext
TMtxExpression.DefineMatrix Method ([In] string, [In] TMtx)

DefineMatrix defines new matrix variable.

Syntax
C#
Visual Basic
public TMatrixValue DefineMatrix([In] string AVarName, [In] TMtx mtx);

If variable with name AVarName already was definded, it will be redefined and all expressions which contain the symbol AVarName will be recompiled before the next evaluation. External matrix may be assigned as values holder. If external matrix is not assigned, internal matrix will be used.

Use parser to evaluate the "A+2*B" formula where A=(2,1; 3, 0) B=(1,0; 1,1) are 2x2 matrices. 

 

using Dew.Math; using Dew.Math.Units; namespace Dew.Examples() { void Example(TMtxExpression MyParser) { // 1. Define variables TMatrixValue A = MyParser.DefineMatrix("A"); TMatrixValue B = MyParser.DefineDouble("B"); // 2. Set values A.Value.SetIt(2,2, false,new double[] {2,1,3,0}); B.Value.SetIt(2,2, false,new double[] {1,0,1,1}); // 3. Add formula and evaluate, MyParser.AddExpr("A+2*B"); Matrix res = new Matrix(false,0,0) res = MyParser.EvaluateMatrix; // res = (4,1; 5,2) } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!